<template>
  <div class="app-container home">
    <!-- <h6>{{ usertime }},王小娟</h6> -->
    <h6>{{ usertime }},{{ username }}</h6>
    <hr />
    <el-row>
      <el-col :span="17">
        <div class="title-header">
          <div class="left">进行中的项目</div>
          <div class="right">全部项目</div>
        </div>

        <div class="grid-content bg-purple">
          <el-row class="myprocard">
            <el-col :span="7" v-for="item in peojectcardInfo"
                    :key="item.projectId">
              <div class="grid-content bg-purple">

                <el-card class="box-card" shadow="hover">
                  <div slot="header" class="clearfix">
                    <b>{{ item.projectName }}</b>
                  </div>
                  <div class="card-content">
                    <div class="left">
                      <div class="top">
                        <p>昨日投入：</p>
                        <p>{{ item.yesFill }}（人天）</p>
                      </div>
                      <div class="bottom">
                        <p>总投入：</p>
                        <p>{{ item.useHour/8 }}（人天）</p>
                      </div>
                    </div>
                    <div class="right">

                      <div class="top">
                        <p>PO：{{ item.totalHour/8 }}（人天）</p>
                      </div>
                      <div class="bottom">
                        <el-progress
                          :color="colors"
                          type="circle"
                          :width="80"
                          :percentage=pjPercent(item)
                        ></el-progress>
                      </div>

                    </div>
                  </div>
                  <el-divider />
                  <div class="card-footer">
                    <div class="projectpeople">
                      <span>项目经理：{{ item.projectManagerName }}</span>
                      <span>{{ dateFormat(item.createTime) }}</span>
                    </div>
                  </div>
                </el-card>

              </div>
            </el-col>
            <el-col :span="7"
            ><div class="grid-content bg-purple"></div
            ></el-col>
            <el-col :span="7"
            ><div class="grid-content bg-purple"></div
            ></el-col>
            <el-col :span="7"
            ><div class="grid-content bg-purple"></div
            ></el-col>
          </el-row>
        </div>
        <div class="grid-content bg-purple">
          <div class="Tips">
            <div class="header-title">
              <strong>使用说明</strong>
              <el-divider />
            </div>
          工时首页暂时不可用，不要问，问就是没做完！
          </div>
        </div></el-col>

      <el-col :span="6">
        <div class="grid-content ">
          <el-card class="box-card" style="min-height: 20em">
            <div slot="header" class="clearfix">
              <span style="font-weight: 600;font-size: 19px">公告！</span>
              <el-button style="float: right; padding: 3px 0" type="text">发布公告</el-button>
            </div>
            <div v-for="o in 5" :key="o">
              XF台账管理系统V1.0.0 beta版本上线测试！！！！！！！
            </div>
          </el-card>

<!--          <el-descriptions title="今日工时提交情况">-->
<!--            <el-descriptions-item label="今日提交">10人</el-descriptions-item>-->
<!--            <el-descriptions-item label="未提交">5人</el-descriptions-item>-->
<!--          </el-descriptions>-->
<!--          <div class="">-->
<!--            <el-card class="box-card" shadow="hover">-->
<!--              <div slot="header" class="clearfix">-->
<!--                <span>最新动态</span>-->
<!--              </div>-->
<!--              <div v-for="o in 12" :key="o" class="text item">-->
<!--                8月10日 16:11 张三 登录系统-->
<!--              </div>-->
<!--            </el-card>-->
<!--          </div>-->
        </div>
      </el-col>
    </el-row>
    <el-divider />
  </div>
</template>

<script>
import { getUserProfile } from "@/api/system/user";
import {getDicttype, projectHourStat} from "@/api/system/project";
import Moment from 'moment'
export default {
  name: "Index",
  data() {
    return {
      colors: [
        {color: '#f56c6c', percentage: 20},
        {color: '#e6a23c', percentage: 40},
        {color: '#5cb87a', percentage: 60},
        {color: '#1989fa', percentage: 80},
        {color: '#6f7ad3', percentage: 100}
      ],
      // 版本号
      version: "",
      usertime: "",
      username: "",
      user: {},
      roleGroup: {},
      postGroup: {},
      peojectcardInfo: []
    };
  },
  created() {
    this.getUser();
    this.init();
  },
  methods: {
    init() {
      projectHourStat().then(res => {
        console.log("peojectcardInfo", res);
        if (res.code == 200) {
          this.peojectcardInfo = res.rows;
        } else {
          this.$message.error(res.msg);
        }
      });
    },

    dateFormat:function(date){
      return Moment(date).format("YYYY-MM-DD")
    },
    // 获取项目进度，取小数点后两位，由于按照工时计算，每8小时算一天
    pjPercent:function (pjItem){
      return ((1 - (pjItem.useHour/8)/(pjItem.totalHour/8))*100).toFixed(2)
    },
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
        this.username = this.user.nickName;
        let datetime = Date().slice(16, 18);
        if (datetime < 13) {
          this.usertime = "上午好";
        } else {
          this.usertime = "下午好";
        }
      });
    },
    goTarget(href) {
      window.open(href, "_blank");
    }
  }
};
</script>

<style scoped lang="scss">
.el-row::before,
.el-row::after {
  display: none;
}
.myprocard {
  // padding: 0 20px;
  display: flex;
  // justify-content: space-between !important;
  align-items: center;
  flex-wrap: wrap;
}
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}

// card
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

//.clearfix:before,
//.clearfix:after {
//  display: table;
//  content: "";
//}
//.clearfix:after {
//  clear: both;
//}

.box-card {
  width: 100%;
  ::v-deep .el-card__body {
    padding: 10px;
  }
  .card-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
    .left {
      width: 55%;
    }
    .header-left {
      font-size: 16px;
      font-weight: 800;
    }
    .right {
      width: 45%;
      .top {
        text-align: center;
      }
      .bottom {
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }
  .card-footer {
    font-size: 8px;
    .projectpeople {
      display: flex;
      justify-content: space-between;
      white-space: nowrap;
    }
  }
}

.el-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  // border-radius: 4px;
  margin-bottom: 30px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  // background: #d3dce6;
}
.bg-purple-light {
  // background: #e5e9f2;
  margin-top: 56px;
  height: 100%;
  ::v-deep .el-descriptions-row {
    display: flex;
    justify-content: space-between;
  }
}
.grid-content {
  // border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
// el-row over
h6 {
  font-weight: 600;
}
.title-header {
  width: 100%;
  height: 56px;
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .right {
    color: black;
    font-weight: 600;
  }
}
.tipItem {
  padding: 8px;
  .position {
    font-size: 18px;
    padding: 8px;
    padding-left: 0px;
  }
}
</style>
